package cn.itcast.bos.service.base.impl;

import cn.itcast.bos.dao.base.CourierRepository;
import cn.itcast.bos.dao.base.StandardRepository;
import cn.itcast.bos.domain.base.Courier;
import cn.itcast.bos.domain.base.Standard;
import cn.itcast.bos.service.base.CourierService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

/**
 * Created by xbqco on 2018/7/12.
 */
@Service("courierService")
@Transactional
public class CourierServiceImpl implements CourierService  {


    // 注入DAO
    @Autowired
    private CourierRepository courierRepository;

    @Override
    public void save(Courier courier) {
        courierRepository.save(courier);
    }

    // 分页查询
    @Override

    public Page<Courier> findPageData(Specification spec,Pageable pageable) {
            return courierRepository.findAll(spec,pageable);
    }

    @Override
    public List<Courier> findAll() {
        return courierRepository.findAll();
    }

    @Override
    public void updateDeltag(Integer id) {
        courierRepository.updateDeltag(id);
    }

    @Override
    public void restore(Integer id) {
        courierRepository.restore(id);
    }

    @Override
    public Page<Courier> findByFixedAreaId(Specification spec, Pageable pageable) {
        return courierRepository.findAll(spec,pageable);
    }

    @Override
    public List<Courier> findBySpec(Specification spec) {
        return courierRepository.findAll(spec);
    }

    @Override
    public List<Object[]> findCourierGroupByCompany() {
        return courierRepository.findCourierGroup();
    }

}
